<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		
	</head>
	<body>
		<h1>网页将在<span>10</span>秒后跳转攀枝花学院</h1>
		<button onclick="fun()">停止跳转</button>
	
		<script type="text/javascript">
			var t;
			function display(){
				t=document.querySelector("h1>span").innerHTML;
				if(t==1){
					return;
				}
				document.querySelector("h1>span").innerHTML=t-1;
				
			}
			var intervalId=setInterval(display,1000);
			function setUrl(){
				window.location.href="https://www.pzhu.cn"
			}
			var time=10000;
			var flag=true;
			var timeOutId= setTimeout(setUrl,time);
			function fun(){
				if(flag){
				clearTimeout(timeOutId);
				clearInterval(intervalId);
				document.querySelector("button").innerHTML="继续"
				flag=false;
				}else{
					time=document.querySelector("h1>span").innerHTML*1000;
					timeOutId=setTimeout(setUrl,time);
					intervalId=setInterval(display,1000);
					flag=true;
					document.querySelector("button").innerHTML="停止跳转"
				}
				
			}
			/**
			 * 拓展任务
			 * 1.点击停止跳转后，按钮变成“继续跳转”
			 * 2.点击继续跳转后，倒计时继续，5000需要变成当前剩余时间
			 */
			
		</script>
	</body>
</html>
